/*
 * Matrix.h
 *
 *  Created on: 20/06/2013
 *      Author: marcio
 */

#ifndef MATRIX_H_
#define MATRIX_H_

template<typename T>
class Matrix {
private:
	Vector< Vector<T > > elems;

	long lin;

	long col;

public:
	Matrix();

	virtual ~Matrix();

	bool addLin();

	bool removeLin(long i);

	void set(long i, long j, T newelem);

	T get(long i, long j);

	Vector<T>* getLin(long i);

	Vector<T>* getCol(long i);

	long numLine();

	long numCol();

	Matrix<T> copy();
};

template<typename T>
Matrix<T>::Matrix(){
	lin = 0;
	this->col = 0;
	elems = new Vector<T>();
}

template<typename T>
Matrix<T>::~Matrix(){
	for(long i = 0; i < lin; i++){
		delete elems[i];
	}
	delete elems;
}

template<typename T>
bool Matrix<T>::addLin(){
	Vector<T>* vt = new Vector<T>();
	elems[lin++] = vt;
}

template<typename T>
bool Matrix<T>::removeLin(long i){
	Vector<double> vt = elems[i];
	for(long j = i+1; j < lin; j++){
		elems[j -1 ] = elems[j];
	}
	delete vt;
}

template<typename T>
void Matrix<T>::set(long i, long j, T newelem){
	elems[i][j] = newelem;
}

template<typename T>
T Matrix<T>::get(long i, long j){
	return elems[i][j];
}

template<typename T>
Vector<T>* Matrix<T>::getLin(long i){
	return elems[i];
}

template<typename T>
Vector<T>* Matrix<T>::getCol(long i){
	//TODO
}

template<typename T>
long Matrix<T>::numLine(){
	return lin;
}

template<typename T>
long Matrix<T>::numCol(){
	return col;
}

#endif /* MATRIX_H_ */
